#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
void xuanzhuan(char* p,int sz)
{
	char a[1000] = {0};
	int b;
	scanf("%s%d", &a,&b);
	if (strcmp(a, "left") == 0)
	{
		for (int i = 0; i < b; i++)
		{
			int flag = p[0];
			for (int j = 0; j < sz-1; j++)
			{
				p[j] = p[j + 1];
			}
			p[sz-1] = flag;
		}
	}
	else if (strcmp(a, "right") == 0)
	{
		for (int i = 0; i < b; i++)
		{
			int flag = p[sz-1];
			for (int j = sz-1; j >0; j--)
			{
				p[j] = p[j - 1];
			}
			p[0] = flag;
		}
	}
}
int main()
{
	char arr[1000] = { 0 };
	scanf("%s", arr);
	int sz = strlen(arr);
	xuanzhuan(arr,sz);
	printf("%s", arr);
	return 0;
}